package lesson09;

import java.util.concurrent.atomic.AtomicInteger;

public class Demo_901 {
    public static void main(String[] args) throws InterruptedException {
        AtomicInteger atomicInteger=new AtomicInteger();
        Thread thread1 = new Thread(() -> {
            for (int i = 0; i < 50000; i++) {
                atomicInteger.getAndDecrement();
            }
        });
        Thread thread2 = new Thread(() -> {
            for (int i = 0; i < 50000; i++) {
                atomicInteger.getAndIncrement();
            }
        });
        thread1.start();
        thread2.start();
        thread1.join();
        thread2.join();
        System.out.println(atomicInteger.get());
    }
}
